import request from "@/utils/request";


let cacheShipmentStatusList = []

export default {
  name: 'ShipmentStatusMixin',
  computed: {
    // 去掉待确认的
    FLShipmentStatusList() {
      const filter = [
        'wait_confirm', 'offline_delivered', 'official_delivered', 'abolished'
      ];
      return this.allShipmentStatusList.filter(item=> filter.indexOf(item.status) === -1)
    }
  },
  data(){
    return {
      allShipmentStatusList: [],
    }
  },
  created() {
    this.getAllShipmentStatus()
  },
  methods: {
    getAllShipmentStatus() {
      if(cacheShipmentStatusList.length > 0){
        this.allShipmentStatusList = cacheShipmentStatusList
      }else{
        request({
          url: '/shipmentV2/getAllShipmentStatus',
        })
          .then(res=>{
            this.allShipmentStatusList = res.data
            cacheShipmentStatusList = res.data
          })
      }

    },
  },
}
